export default {
  /**
   * 判断动画
   * @param {*} animationType
   * @param {*} direction
   */
  getAnimationType(animationType, direction) {

    // debugger
    switch (parseInt(animationType)) {
      case 0:
        if (direction == 0) {
          return "fadeInLeft";
        } else if (direction == 1) {
          return "fadeInDown";
        } else if (direction == 2) {
          return "fadeInRight";
        } else if (direction == 3) {
          return "fadeInUp";
        }
        break;
      case 1:
        return "fadeInRight";
        break;
      case 2:
        if (direction == 0) {
          return "bounceInLeft";
        } else if (direction == 1) {
          return "bounceInDown";
        } else if (direction == 2) {
          return "bounceInRight";
        } else if (direction == 3) {
          return "bounceInUp";
        }
        break;
      case 3:
        return "bounceIn";
        break;
      case 4:
        return "zoomIn";
        break;
      case 5:
        return "rubberBand";
        break;
      case 6:
        return "wobble";
        break;
      case 7:
        return "rotateIn";
        break;
      case 8:
        return "flip";
        break;
      case 9:
        return "swing";
        break;
      case 10:
        return "fadeOut";
        break;
      case 11:
        return "flipOutY";
        break;
      case 12:
        return "rotateIn";
        break;
      case 13:
        return "lightSpeedIn";
        break;
      case 14:
        return "bounceOut";
        break;
      case 15:
        return "rollOut";
        break;
      case 16:
        return "lightSpeedOut";
        break;
      case 17:
        return "fadeOutLeft";
        break;
      case 18:
        return "zoomOut";
        break;
      case 19:
        return "bounceOutLeft";
        break;
      case 20:
        return "flipInY";
        break;
      case 21:
        return "tada";
        break;
      case 22:
        return "jello";
        break;
      case 23:
        return "shake";
        break;
      case 24:
        return "flipInX";
        break;
      case 25:
        return "flipOutY";
        break;
      case 26:
        return "twisterInDown";
        break;
      case 27:
        return "puffIn";
        break;
      case 28:
        return "puffOut";
        break;
      case 29:
        return "slideInDown";
        break;
      case 30:
        return "slideOutUp";
        break;
      case 31:
        return "twisterInUp";
        break;
      case 32:
        return "hinge";
        break;
    }
  },


  htmlEncode(str) {
    var s = "";
    if (str != undefined) {
      if (str.length == 0) return "";
      //s = str.replace(/&/g, "&gt;");
      //s = str.replace(/&/g, "&gt;");
      s = s.replace(/</g, "&lt;");
      s = s.replace(/>/g, "&gt;");
      s = s.replace(/ /g, "&nbsp;");
      s = s.replace(/\'/g, "&#39;");
      s = s.replace(/\"/g, "&quot;");
      // s = s.replace(/\n/g, "<br>");
      // s = s.replace(/&nbsp;/g, " ");
      return s;
    }
  },

  htmlDecode(str) {
    var s = "";
    if (str != undefined) {
      if (str.length == 0) return "";
      s = str.replace(/amp;/g, "");
      //s = str.replace(/&amp;/g, "");
      s = s.replace(/&lt;/g, "<");
      s = s.replace(/&gt;/g, ">");
      // s = s.replace(/&nbsp;/g, " ");
      s = s.replace(/&#39;/g, "\'");
      s = s.replace(/&quot;/g, "\"");
      // s = s.replace(/<br>/g, "\n");
      // s = s.replace(/<div>/g, "</br>");
      s = s.replace(/<\/div>/g, "");
      s = s.replace(/ /g, "&nbsp;");
      return s;
    }
  },

  initSwiper(swiper){
    return {
      // NotNextTick is a component's own property, and if notNextTick is set to true, the component will not instantiate the swiper through NextTick, which means you can get the swiper object the first time (if you need to use the get swiper object to do what Things, then this property must be true)
      // notNextTick是一个组件自有属性，如果notNextTick设置为true，组件则不会通过NextTick来实例化swiper，也就意味着你可以在第一时间获取到swiper对象，假如你需要刚加载遍使用获取swiper对象来做什么事，那么这个属性一定要是true
      notNextTick: true,
      // swiper configs 所有的配置同swiper官方api配置
      autoplayDisableOnInteraction: false,
      direction: 'vertical',
      loop: false,
      grabCursor: true,
      setWrapperSize: true,
      autoHeight: true,
      paginationClickable: true,
      pagination: '.swiper-pagination',
      paginationType: 'progress',
      observer: true,//修改swiper自己或子元素时，自动初始化swiper
      observeParents: true,//修改swiper的父元素时，自动初始化swiper

//          prevButton: '.swiper-button-prev',
//          nextButton: '.swiper-button-next',
//          scrollbar: '.swiper-scrollbar',
      mousewheelControl: true,
      // if you need use plugins in the swiper, you can config in here like this
      // 如果自行设计了插件，那么插件的一些配置相关参数，也应该出现在这个对象中，如下debugger
      debugger: true,
      autoplayStopOnLast: true,
      //					 swiper callbacks
      // swiper的各种回调函数也可以出现在这个对象中，和swiper官方一样

      onInit: swiper => {
        _self.swipers = swiper;
        this.scrollIndex = swiper.realIndex
        console.log("init:" + swiper.realIndex)
        this.initSwiper();
        this.pageStr = swiper.realIndex + 1 + "/" + this.pagesData.length;
      },
      onSlideChangeStart: swiper => {
        _self.swipers = swiper;
      },
      onTransitionStart: swiper => {
        this.scrollIndex = swiper.realIndex
        this.pageStr = swiper.realIndex + 1 + "/" + this.pagesData.length;
      }
    }
  }

}
